package org.geek4j.business.service.impl;

import java.util.List;

import org.geek4j.business.repository.mybatis.domain.User;
import org.geek4j.business.repository.mybatis.mapper.UserMapper;
import org.geek4j.business.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author Geek4J
 * @description UserService interface
 * 
 */
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;

	@Transactional
	@Override
	public void save(User user) {
		userMapper.save(user);
	}

	@Transactional
	@Override
	public void save(List<User> users) {
		for (User user : users) {
			userMapper.save(user);
		}
	}

	@Override
	public User findById(Long id) {
		return userMapper.findById(id);
	}

	@Override
	public User findByIdWithRoles(Long id) {
		return userMapper.findByIdWithRoles(id);
	}

}